package Client;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.rmi.RemoteException;
import javax.microedition.rms.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.location.*;
import org.bouncycastle.crypto.DataLengthException;
import org.bouncycastle.crypto.InvalidCipherTextException;
import org.bouncycastle.util.encoders.Base64;
import org.kxml.Xml;
import org.kxml.parser.ParseEvent;
import org.kxml.parser.XmlParser;
import org.netbeans.microedition.util.SimpleCancellableTask;
import ru.zombator.services.smartdating.OperationStatus;
import ru.zombator.services.smartdating.PersonalData;
import ru.zombator.services.smartdating.ResultWithStatusOfstring;
import ru.zombator.services.smartdating.SmartDating;
import ru.zombator.services.smartdating.SmartDating_Stub;

/**
 * @author Bocman
 */
public class ClientMIDlet extends MIDlet implements CommandListener {

    private boolean midletPaused = false;
    private RecordStore serviceStore;
    private String userName = "USER";
    private String passwordUser = "PASSWORD";
    private static String serverName = "SERVER";
    private static String serverPort = "8080";
    private String currentUser = "current";
    private static byte[] sessionKey;
    private static byte[] sessionKeyHash;
    private static boolean connect = false;
    private static SmartDating service;
    private static SetLocationThread LocationThread = new SetLocationThread();
    private static String guid;
    private PersonalData UserData = new PersonalData();
    private static boolean initial = false;
    //<editor-fold defaultstate="collapsed" desc=" Generated Fields ">//GEN-BEGIN:|fields|0|
    private Command exitCommand1;
    private Command helpCommand1;
    private Command backCommand3;
    private Command backCommand4;
    private Command backCommand5;
    private Command okCommand1;
    private Command okCommand2;
    private Command backCommand7;
    private Command okCommand4;
    private Command okCommand3;
    private Command backCommand8;
    private Command okCommand5;
    private Command okCommand6;
    private Command backCommand9;
    private Command backCommand10;
    private Command backCommand11;
    private Command cancelCommand1;
    private Command cancelCommand;
    private Command cancelCommand2;
    private Command okCommand7;
    private Command itemCommand;
    private Command itemCommand3;
    private Command cancelCommand3;
    private Command itemCommand2;
    private Command backCommand1;
    private Command itemCommand1;
    private Command backCommand2;
    private Command backCommand;
    private Command okCommand;
    private Command cancelCommand4;
    private Command itemCommand4;
    private Command backCommand6;
    private Command backCommand12;
    private Command okCommand8;
    private Command cancelCommand5;
    private List list;
    private Form form1;
    private StringItem stringItem3;
    private Form form2;
    private StringItem stringItem4;
    private Form form3;
    private TextField textField;
    private Spacer spacer;
    private TextField textField1;
    private List list1;
    private Form form4;
    private TextField textField3;
    private TextField textField2;
    private Form form5;
    private ChoiceGroup choiceGroup;
    private List list2;
    private List list3;
    private Form form7;
    private TextField textField4;
    private TextField textField7;
    private Form form8;
    private StringItem stringItem7;
    private StringItem stringItem6;
    private StringItem stringItem5;
    private StringItem stringItem17;
    private StringItem stringItem16;
    private StringItem stringItem18;
    private StringItem stringItem1;
    private StringItem stringItem12;
    private StringItem stringItem13;
    private StringItem stringItem14;
    private StringItem stringItem15;
    private StringItem stringItem2;
    private StringItem stringItem9;
    private StringItem stringItem10;
    private StringItem stringItem11;
    private Form form;
    private TextField textField6;
    private TextField textField5;
    private Alert alert;
    private Alert alert1;
    private Form form6;
    private TextField textField22;
    private Alert alert2;
    private Alert alert3;
    private Font font;
    private SimpleCancellableTask task;
    private Ticker ticker;
    //</editor-fold>//GEN-END:|fields|0|

    /**
     * The ClientMIDlet constructor.
     */
    public ClientMIDlet(){
        try {
            serviceStore = RecordStore.openRecordStore("Record", true);
            if (serviceStore.getNumRecords() > 0){
                setUserName(new String(serviceStore.getRecord(1), 0, serviceStore.getRecord(1).length));
                if (getUserName().equals(" "))
                    setUserName("");
                setUserPassword(new String(serviceStore.getRecord(2), 0, serviceStore.getRecord(2).length));
                if (getUserPassword().equals(" "))
                    setUserPassword("");
                setServerName(new String(serviceStore.getRecord(3), 0, serviceStore.getRecord(3).length));
                if (getServerName().equals(" "))
                    setServerName("");
                setServerPort(new String(serviceStore.getRecord(4), 0, serviceStore.getRecord(4).length));
                if (getServerPort().equals(" "))
                    setServerPort("");
            }
            serviceStore.closeRecordStore();
        }
        catch (RecordStoreException ex) {
        }
        service =  new SmartDating_Stub();
    }

    //<editor-fold defaultstate="collapsed" desc=" Generated Methods ">//GEN-BEGIN:|methods|0|
    //</editor-fold>//GEN-END:|methods|0|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">//GEN-BEGIN:|0-initialize|0|0-preInitialize
    /**
     * Initilizes the application.
     * It is called only once when the MIDlet is started. The method is called before the <code>startMIDlet</code> method.
     */
    private void initialize() {//GEN-END:|0-initialize|0|0-preInitialize
        // write pre-initialize user code here
        textField = new TextField("\u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435 \u0443\u0447\u0435\u0442\u043D\u043E\u0439 \u0437\u0430\u043F\u0438\u0441\u0438", null, 32, TextField.ANY);//GEN-BEGIN:|0-initialize|1|0-postInitialize
        textField.setLayout(ImageItem.LAYOUT_CENTER | Item.LAYOUT_TOP | Item.LAYOUT_BOTTOM | Item.LAYOUT_VCENTER);
        textField1 = new TextField("\u041F\u0430\u0440\u043E\u043B\u044C", null, 32, TextField.ANY | TextField.PASSWORD);
        textField1.setLayout(ImageItem.LAYOUT_CENTER | Item.LAYOUT_TOP | Item.LAYOUT_BOTTOM | Item.LAYOUT_VCENTER);//GEN-END:|0-initialize|1|0-postInitialize
        // write post-initialize user code here
    }//GEN-BEGIN:|0-initialize|2|
    //</editor-fold>//GEN-END:|0-initialize|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">//GEN-BEGIN:|3-startMIDlet|0|3-preAction
    /**
     * Performs an action assigned to the Mobile Device - MIDlet Started point.
     */
    public void startMIDlet() {//GEN-END:|3-startMIDlet|0|3-preAction
        switchDisplayable(null, getList());//GEN-LINE:|3-startMIDlet|1|3-postAction
        LocationThread.start();
    }//GEN-BEGIN:|3-startMIDlet|2|
    //</editor-fold>//GEN-END:|3-startMIDlet|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">//GEN-BEGIN:|4-resumeMIDlet|0|4-preAction
    /**
     * Performs an action assigned to the Mobile Device - MIDlet Resumed point.
     */
    public void resumeMIDlet() {//GEN-END:|4-resumeMIDlet|0|4-preAction

        switchDisplayable(null, getList());//GEN-LINE:|4-resumeMIDlet|1|4-postAction

    }//GEN-BEGIN:|4-resumeMIDlet|2|
    //</editor-fold>//GEN-END:|4-resumeMIDlet|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">//GEN-BEGIN:|5-switchDisplayable|0|5-preSwitch
    /**
     * Switches a current displayable in a display. The <code>display</code> instance is taken from <code>getDisplay</code> method. This method is used by all actions in the design for switching displayable.
     * @param alert the Alert which is temporarily set to the display; if <code>null</code>, then <code>nextDisplayable</code> is set immediately
     * @param nextDisplayable the Displayable to be set
     */
    public void switchDisplayable(Alert alert, Displayable nextDisplayable) {//GEN-END:|5-switchDisplayable|0|5-preSwitch
        // write pre-switch user code here
        Display display = getDisplay();//GEN-BEGIN:|5-switchDisplayable|1|5-postSwitch
        if (alert == null) {
            display.setCurrent(nextDisplayable);
        } else {
            display.setCurrent(alert, nextDisplayable);
        }//GEN-END:|5-switchDisplayable|1|5-postSwitch
        // write post-switch user code here
    }//GEN-BEGIN:|5-switchDisplayable|2|
    //</editor-fold>//GEN-END:|5-switchDisplayable|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables ">//GEN-BEGIN:|7-commandAction|0|7-preCommandAction
    /**
     * Called by a system to indicated that a command has been invoked on a particular displayable.
     * @param command the Command that was invoked
     * @param displayable the Displayable where the command was invoked
     */
    public void commandAction(Command command, Displayable displayable) {//GEN-END:|7-commandAction|0|7-preCommandAction

        if (displayable == alert) {//GEN-BEGIN:|7-commandAction|1|396-preAction
            if (command == backCommand1) {//GEN-END:|7-commandAction|1|396-preAction

                switchDisplayable(null, getList());//GEN-LINE:|7-commandAction|2|396-postAction

            }//GEN-BEGIN:|7-commandAction|3|400-preAction
        } else if (displayable == alert1) {
            if (command == backCommand2) {//GEN-END:|7-commandAction|3|400-preAction

                switchDisplayable(null, getForm3());//GEN-LINE:|7-commandAction|4|400-postAction

            }//GEN-BEGIN:|7-commandAction|5|439-preAction
        } else if (displayable == alert2) {
            if (command == backCommand6) {//GEN-END:|7-commandAction|5|439-preAction

                switchDisplayable(null, getList2());//GEN-LINE:|7-commandAction|6|439-postAction

            }//GEN-BEGIN:|7-commandAction|7|455-preAction
        } else if (displayable == alert3) {
            if (command == cancelCommand5) {//GEN-END:|7-commandAction|7|455-preAction

                switchDisplayable(null, getForm3());//GEN-LINE:|7-commandAction|8|455-postAction

            } else if (command == okCommand8) {//GEN-LINE:|7-commandAction|9|458-preAction

                switchDisplayable(null, getForm3());//GEN-LINE:|7-commandAction|10|458-postAction
                OperationStatus del = OperationStatus.Success;
                try {
                   del = deleteUser(textField22.getString());
                } catch (RemoteException ex) {
                } catch (InvalidCipherTextException ex) {
                }
                switchDisplayable(null, getAlert1());
                if (del == OperationStatus.Success){
                  alert1.setTitle("Успешно");
                  alert1.setString(del.getValue() + ": учетная запись успешно удалена");
                }
                else {
                  alert1.setTitle("Ошибка");
                  alert1.setString(del.getValue());
                }
            }//GEN-BEGIN:|7-commandAction|11|387-preAction
        } else if (displayable == form) {
            if (command == backCommand) {//GEN-END:|7-commandAction|11|387-preAction

                switchDisplayable(null, getForm3());//GEN-LINE:|7-commandAction|12|387-postAction

            } else if (command == okCommand) {//GEN-LINE:|7-commandAction|13|385-preAction
                OperationStatus regis = OperationStatus.Success;
                switchDisplayable(null, getForm3());//GEN-LINE:|7-commandAction|14|385-postAction
             try {
                regis = registerUser(textField5.getString(), textField6.getString());
             } catch (InvalidCipherTextException ex) {
             } catch (RemoteException ex) {
             } catch (UnsupportedEncodingException ex) {
             }
             switchDisplayable(null, getAlert1());
             if (regis == OperationStatus.Success){
                alert1.setTitle("Успешно");
                alert1.setString(regis.getValue() + ": регистрация произведена успешно");
                textField.setString(textField5.getString());
                textField1.setString(textField6.getString());
                setUserName(textField5.getString());
                setUserPassword(textField6.getString());
             }
             else{
                 alert1.setTitle("Ошибка");
                 alert1.setString(regis.getValue());
             }
            }//GEN-BEGIN:|7-commandAction|15|161-preAction
        } else if (displayable == form1) {
            if (command == backCommand4) {//GEN-END:|7-commandAction|15|161-preAction

                switchDisplayable(null, getList());//GEN-LINE:|7-commandAction|16|161-postAction

            }//GEN-BEGIN:|7-commandAction|17|168-preAction
        } else if (displayable == form2) {
            if (command == backCommand5) {//GEN-END:|7-commandAction|17|168-preAction

                switchDisplayable(null, getList());//GEN-LINE:|7-commandAction|18|168-postAction

            }//GEN-BEGIN:|7-commandAction|19|325-preAction
        } else if (displayable == form3) {
            if (command == cancelCommand1) {//GEN-END:|7-commandAction|19|325-preAction

                switchDisplayable(null, getList1());//GEN-LINE:|7-commandAction|20|325-postAction
                if (!getUserName().equals(textField.getString()))
                    textField.setString(getUserName());
                if (!getUserPassword().equals(textField1.getString()))
                    textField1.setString(getUserPassword());
            } else if (command == itemCommand) {//GEN-LINE:|7-commandAction|21|372-preAction
                switchDisplayable(null, getForm());//GEN-LINE:|7-commandAction|22|372-postAction

            } else if (command == itemCommand1) {//GEN-LINE:|7-commandAction|23|393-preAction

                switchDisplayable(null, getForm6());//GEN-LINE:|7-commandAction|24|393-postAction

            } else if (command == okCommand2) {//GEN-LINE:|7-commandAction|25|210-preAction

                switchDisplayable(null, getList1());//GEN-LINE:|7-commandAction|26|210-postAction

                setUserName(textField.getString());
                setUserPassword(textField1.getString());
            }//GEN-BEGIN:|7-commandAction|27|322-preAction
        } else if (displayable == form4) {
            if (command == cancelCommand) {//GEN-END:|7-commandAction|27|322-preAction

                switchDisplayable(null, getList1());//GEN-LINE:|7-commandAction|28|322-postAction

              if (!getServerName().equals(textField2.getString()))
                  textField2.setString(getServerName());
              if (!getServerPort().equals(textField3.getString()))
                  textField3.setString(getServerPort());
            } else if (command == okCommand3) {//GEN-LINE:|7-commandAction|29|227-preAction

                switchDisplayable(null, getList1());//GEN-LINE:|7-commandAction|30|227-postAction

                setServerName(textField2.getString());
                setServerPort(textField3.getString());
            }//GEN-BEGIN:|7-commandAction|31|240-preAction
        } else if (displayable == form5) {
            if (command == backCommand7) {//GEN-END:|7-commandAction|31|240-preAction

                switchDisplayable(null, getList1());//GEN-LINE:|7-commandAction|32|240-postAction

            } else if (command == okCommand4) {//GEN-LINE:|7-commandAction|33|238-preAction

                switchDisplayable(null, getList1());//GEN-LINE:|7-commandAction|34|238-postAction

            }//GEN-BEGIN:|7-commandAction|35|443-preAction
        } else if (displayable == form6) {
            if (command == cancelCommand4) {//GEN-END:|7-commandAction|35|443-preAction

                switchDisplayable(null, getForm3());//GEN-LINE:|7-commandAction|36|443-postAction

            } else if (command == itemCommand4) {//GEN-LINE:|7-commandAction|37|445-preAction

//GEN-LINE:|7-commandAction|38|445-postAction
                switchDisplayable(null, getAlert3());
                alert3.setString("Вы действительно хотите удалить учетную запись "
                        + textField22.getString() + "???");
            }//GEN-BEGIN:|7-commandAction|39|332-preAction
        } else if (displayable == form7) {
            if (command == cancelCommand2) {//GEN-END:|7-commandAction|39|332-preAction

                switchDisplayable(null, getList2());//GEN-LINE:|7-commandAction|40|332-postAction

                textField4.setString("");
            } else if (command == okCommand7) {//GEN-LINE:|7-commandAction|41|330-preAction

                switchDisplayable(null, getList2());//GEN-LINE:|7-commandAction|42|330-postAction
                try {
                   sendMessage();
                } catch (DataLengthException ex) {
                } catch (IllegalStateException ex) {
                } catch (InvalidCipherTextException ex) {
                } catch (UnsupportedEncodingException ex) {
                }
                textField4.setString("");
            }//GEN-BEGIN:|7-commandAction|43|337-preAction
        } else if (displayable == form8) {
            if (command == backCommand10) {//GEN-END:|7-commandAction|43|337-preAction

                switchDisplayable(null, getList2());//GEN-LINE:|7-commandAction|44|337-postAction

            }//GEN-BEGIN:|7-commandAction|45|49-preAction
        } else if (displayable == list) {
            if (command == List.SELECT_COMMAND) {//GEN-END:|7-commandAction|45|49-preAction

                listAction();//GEN-LINE:|7-commandAction|46|49-postAction

            } else if (command == exitCommand1) {//GEN-LINE:|7-commandAction|47|144-preAction

                exitMIDlet();//GEN-LINE:|7-commandAction|48|144-postAction

            } else if (command == helpCommand1) {//GEN-LINE:|7-commandAction|49|149-preAction

                switchDisplayable(null, getForm1());//GEN-LINE:|7-commandAction|50|149-postAction

            }//GEN-BEGIN:|7-commandAction|51|194-preAction
        } else if (displayable == list1) {
            if (command == List.SELECT_COMMAND) {//GEN-END:|7-commandAction|51|194-preAction

                list1Action();//GEN-LINE:|7-commandAction|52|194-postAction

            } else if (command == okCommand1) {//GEN-LINE:|7-commandAction|53|202-preAction

                switchDisplayable(null, getList());//GEN-LINE:|7-commandAction|54|202-postAction

            }//GEN-BEGIN:|7-commandAction|55|312-preAction
        } else if (displayable == list2) {
            if (command == List.SELECT_COMMAND) {//GEN-END:|7-commandAction|55|312-preAction

                list2Action();//GEN-LINE:|7-commandAction|56|312-postAction

            } else if (command == backCommand9) {//GEN-LINE:|7-commandAction|57|319-preAction

                switchDisplayable(null, getList());//GEN-LINE:|7-commandAction|58|319-postAction

            } else if (command == itemCommand2) {//GEN-LINE:|7-commandAction|59|403-preAction

                switchDisplayable(null, getForm8());//GEN-LINE:|7-commandAction|60|403-postAction
                try {
                    getInfoUser(getXMLInfoUser(), 0);
                } catch (IOException ex) {
                }
            } else if (command == okCommand6) {//GEN-LINE:|7-commandAction|61|316-preAction

                switchDisplayable(null, getList3());//GEN-LINE:|7-commandAction|62|316-postAction

            }//GEN-BEGIN:|7-commandAction|63|345-preAction
        } else if (displayable == list3) {
            if (command == List.SELECT_COMMAND) {//GEN-END:|7-commandAction|63|345-preAction

                list3Action();//GEN-LINE:|7-commandAction|64|345-postAction

            } else if (command == backCommand11) {//GEN-LINE:|7-commandAction|65|350-preAction

                switchDisplayable(null, getList2());//GEN-LINE:|7-commandAction|66|350-postAction

            }//GEN-BEGIN:|7-commandAction|67|7-postCommandAction
        }//GEN-END:|7-commandAction|67|7-postCommandAction

    }//GEN-BEGIN:|7-commandAction|68|
    //</editor-fold>//GEN-END:|7-commandAction|68|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: list ">//GEN-BEGIN:|47-getter|0|47-preInit
    /**
     * Returns an initiliazed instance of list component.
     * @return the initialized component instance
     */
    public List getList() {
        if (list == null) {//GEN-END:|47-getter|0|47-preInit

            list = new List("\u041C\u043E\u0431\u0438\u043B\u044C\u043D\u044B\u0439 \u043A\u043B\u0438\u0435\u043D\u0442", Choice.IMPLICIT);//GEN-BEGIN:|47-getter|1|47-postInit
            list.append("\u041F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u0435", null);
            list.append("\u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0430", null);
            list.append("\u041F\u043E\u043C\u043E\u0449\u044C", null);
            list.append("\u041E \u043F\u0440\u043E\u0433\u0440\u0430\u043C\u043C\u0435", null);
            list.append("\u0412\u044B\u0445\u043E\u0434", null);
            list.setTicker(getTicker());
            list.addCommand(getExitCommand1());
            list.addCommand(getHelpCommand1());
            list.setCommandListener(this);
            list.setSelectedFlags(new boolean[] { false, false, false, false, false });//GEN-END:|47-getter|1|47-postInit

        }//GEN-BEGIN:|47-getter|2|
        return list;
    }
    //</editor-fold>//GEN-END:|47-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: listAction ">//GEN-BEGIN:|47-action|0|47-preAction
    /**
     * Performs an action assigned to the selected list element in the list component.
     */
    public void listAction() {//GEN-END:|47-action|0|47-preAction

        String __selectedString = getList().getString(getList().getSelectedIndex());//GEN-BEGIN:|47-action|1|92-preAction
        if (__selectedString != null) {
            if (__selectedString.equals("\u041F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u0435")) {//GEN-END:|47-action|1|92-preAction
                OperationStatus conn = OperationStatus.Success;
                try {
                    conn = connectToServer(getUserName(), getUserPassword());
                } catch (UnsupportedEncodingException ex) {
                } catch (DataLengthException ex) {
                } catch (IllegalStateException ex) {
                } catch (InvalidCipherTextException ex) {
                } catch (RemoteException ex) {
                }
                if (connect){
                    try {
                        setLocationUser();
                    } catch (RemoteException ex) {
                    }
                    switchDisplayable(null, getList2());//GEN-LINE:|47-action|2|92-postAction
                    list.delete(0);
                    list.insert(0, "Список контактов", null);
                    list.insert(1, "Отключение", null);
                    list.setSelectedIndex(0, true);
                    try {
                         getListUsers();
                    } catch (RemoteException ex) {
                    } catch (IOException ex) {
                    }
                 }
                else {
                     switchDisplayable(null, getAlert());
                     alert.setString(conn.getValue());
                }
            } else if (__selectedString.equals("\u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0430")) {//GEN-LINE:|47-action|3|93-preAction

                switchDisplayable(null, getList1());//GEN-LINE:|47-action|4|93-postAction

            } else if (__selectedString.equals("\u041F\u043E\u043C\u043E\u0449\u044C")) {//GEN-LINE:|47-action|5|95-preAction

                switchDisplayable(null, getForm1());//GEN-LINE:|47-action|6|95-postAction

            } else if (__selectedString.equals("\u041E \u043F\u0440\u043E\u0433\u0440\u0430\u043C\u043C\u0435")) {//GEN-LINE:|47-action|7|94-preAction

                switchDisplayable(null, getForm2());//GEN-LINE:|47-action|8|94-postAction

            } else if (__selectedString.equals("\u0412\u044B\u0445\u043E\u0434")) {//GEN-LINE:|47-action|9|52-preAction

                exitMIDlet();//GEN-LINE:|47-action|10|52-postAction
            } else if (__selectedString.equals("Отключение")){
                OperationStatus disconn = OperationStatus.Success;
                try {
                    disconn = disconnectFromServer();
                } catch (RemoteException ex) {
                }
                if (disconn == OperationStatus.Success){
                    list.delete(1);
                    list.delete(0);
                    list.insert(0, "Подключение", null);
                    int sz = list2.size();
                    for (int i = 0; i <= sz; i++){
                        list2.delete(0);
                    }
                }
                else{
                    switchDisplayable(null, getAlert());
                    alert.setString(disconn.getValue());
                }
              }
              else if (__selectedString.equals("Список контактов")){

                switchDisplayable(null, getList2());
              }//GEN-BEGIN:|47-action|11|47-postAction
        }//GEN-END:|47-action|11|47-postAction
        // enter post-action user code here
    }//GEN-BEGIN:|47-action|12|
    //</editor-fold>//GEN-END:|47-action|12|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand1 ">//GEN-BEGIN:|143-getter|0|143-preInit
    /**
     * Returns an initiliazed instance of exitCommand1 component.
     * @return the initialized component instance
     */
    public Command getExitCommand1() {
        if (exitCommand1 == null) {//GEN-END:|143-getter|0|143-preInit

            exitCommand1 = new Command("\u0412\u044B\u0445\u043E\u0434", Command.EXIT, 0);//GEN-LINE:|143-getter|1|143-postInit

        }//GEN-BEGIN:|143-getter|2|
        return exitCommand1;
    }
    //</editor-fold>//GEN-END:|143-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: helpCommand1 ">//GEN-BEGIN:|148-getter|0|148-preInit
    /**
     * Returns an initiliazed instance of helpCommand1 component.
     * @return the initialized component instance
     */
    public Command getHelpCommand1() {
        if (helpCommand1 == null) {//GEN-END:|148-getter|0|148-preInit

            helpCommand1 = new Command("\u0421\u043F\u0440\u0430\u0432\u043A\u0430", Command.HELP, 0);//GEN-LINE:|148-getter|1|148-postInit

        }//GEN-BEGIN:|148-getter|2|
        return helpCommand1;
    }
    //</editor-fold>//GEN-END:|148-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand3 ">//GEN-BEGIN:|151-getter|0|151-preInit
    /**
     * Returns an initiliazed instance of backCommand3 component.
     * @return the initialized component instance
     */
    public Command getBackCommand3() {
        if (backCommand3 == null) {//GEN-END:|151-getter|0|151-preInit

            backCommand3 = new Command("\u041D\u0430\u0437\u0430\u0434", Command.BACK, 0);//GEN-LINE:|151-getter|1|151-postInit

        }//GEN-BEGIN:|151-getter|2|
        return backCommand3;
    }
    //</editor-fold>//GEN-END:|151-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand4 ">//GEN-BEGIN:|160-getter|0|160-preInit
    /**
     * Returns an initiliazed instance of backCommand4 component.
     * @return the initialized component instance
     */
    public Command getBackCommand4() {
        if (backCommand4 == null) {//GEN-END:|160-getter|0|160-preInit

            backCommand4 = new Command("\u041D\u0430\u0437\u0430\u0434", Command.BACK, 0);//GEN-LINE:|160-getter|1|160-postInit

        }//GEN-BEGIN:|160-getter|2|
        return backCommand4;
    }
    //</editor-fold>//GEN-END:|160-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: form1 ">//GEN-BEGIN:|159-getter|0|159-preInit
    /**
     * Returns an initiliazed instance of form1 component.
     * @return the initialized component instance
     */
    public Form getForm1() {
        if (form1 == null) {//GEN-END:|159-getter|0|159-preInit

            form1 = new Form("\u041F\u043E\u043C\u043E\u0449\u044C", new Item[] { getStringItem3() });//GEN-BEGIN:|159-getter|1|159-postInit
            form1.addCommand(getBackCommand4());
            form1.setCommandListener(this);//GEN-END:|159-getter|1|159-postInit

        }//GEN-BEGIN:|159-getter|2|
        return form1;
    }
    //</editor-fold>//GEN-END:|159-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem3 ">//GEN-BEGIN:|165-getter|0|165-preInit
    /**
     * Returns an initiliazed instance of stringItem3 component.
     * @return the initialized component instance
     */
    public StringItem getStringItem3() {
        if (stringItem3 == null) {//GEN-END:|165-getter|0|165-preInit

            stringItem3 = new StringItem("", "\u041F\u0440\u043E\u0433\u0440\u0430\u043C\u043C\u0430 \u044F\u0432\u043B\u044F\u0435\u0442\u0441\u044F \u043C\u043E\u0431\u0438\u043B\u044C\u043D\u044B\u043C \u043A\u043B\u0438\u0435\u043D\u0442\u043E\u043C \u0441\u0438\u0441\u0442\u0435\u043C\u044B \u043E\u0431\u0449\u0435\u043D\u0438\u044F. \u0414\u043B\u044F \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u044F \u0438 \u043E\u0431\u0449\u0435\u043D\u0438\u044F \u043D\u0435\u043E\u0431\u0445\u043E\u0434\u0438\u043C\u043E \u0437\u0430\u0439\u0442\u0438 \u0432 \u043F\u0443\u043D\u043A\u0442 \u043C\u0435\u043D\u044E \"\u041F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u0435\". \u0412 \u043F\u0443\u043D\u043A\u0442\u0435 \u043C\u0435\u043D\u044E \"\u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438\" \u0445\u0440\u0430\u043D\u044F\u0442\u0441\u044F \u043D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438 \u0432\u0430\u0448\u0435\u0433\u043E \u043F\u0440\u043E\u0444\u0438\u043B\u044F. \u0422\u0430\u043A\u0436\u0435 \u0435\u0441\u043B\u0438 \u0443 \u0432\u0430\u0441 \u043E\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0435\u0449\u0435 \u043F\u0440\u043E\u0444\u0438\u043B\u044C, \u0442\u043E \u043C\u043E\u0436\u043D\u043E \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043E\u0432\u0430\u0442\u044C\u0441\u044F \u0432 \u0441\u0438\u0441\u0442\u0435\u043C\u0435.");//GEN-BEGIN:|165-getter|1|165-postInit
            stringItem3.setLayout(ImageItem.LAYOUT_CENTER);//GEN-END:|165-getter|1|165-postInit

        }//GEN-BEGIN:|165-getter|2|
        return stringItem3;
    }
    //</editor-fold>//GEN-END:|165-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand5 ">//GEN-BEGIN:|167-getter|0|167-preInit
    /**
     * Returns an initiliazed instance of backCommand5 component.
     * @return the initialized component instance
     */
    public Command getBackCommand5() {
        if (backCommand5 == null) {//GEN-END:|167-getter|0|167-preInit

            backCommand5 = new Command("\u041D\u0430\u0437\u0430\u0434", Command.BACK, 0);//GEN-LINE:|167-getter|1|167-postInit

        }//GEN-BEGIN:|167-getter|2|
        return backCommand5;
    }
    //</editor-fold>//GEN-END:|167-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: form2 ">//GEN-BEGIN:|166-getter|0|166-preInit
    /**
     * Returns an initiliazed instance of form2 component.
     * @return the initialized component instance
     */
    public Form getForm2() {
        if (form2 == null) {//GEN-END:|166-getter|0|166-preInit

            form2 = new Form("\u041E \u043F\u0440\u043E\u0433\u0440\u0430\u043C\u043C\u0435", new Item[] { getStringItem4() });//GEN-BEGIN:|166-getter|1|166-postInit
            form2.addCommand(getBackCommand5());
            form2.setCommandListener(this);//GEN-END:|166-getter|1|166-postInit

        }//GEN-BEGIN:|166-getter|2|
        return form2;
    }
    //</editor-fold>//GEN-END:|166-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem4 ">//GEN-BEGIN:|170-getter|0|170-preInit
    /**
     * Returns an initiliazed instance of stringItem4 component.
     * @return the initialized component instance
     */
    public StringItem getStringItem4() {
        if (stringItem4 == null) {//GEN-END:|170-getter|0|170-preInit

            stringItem4 = new StringItem("", "\u041F\u0440\u043E\u0433\u0440\u0430\u043C\u043C\u0430 \u044F\u0432\u043B\u044F\u0435\u0442\u0441\u044F \u043C\u043E\u0431\u0438\u043B\u044C\u043D\u044B\u043C \u043A\u043B\u0438\u0435\u043D\u0442\u043E\u043C \u0441\u0438\u0441\u0442\u0435\u043C\u044B \u043E\u0431\u0449\u0435\u043D\u0438\u044F \u043B\u044E\u0434\u0435\u0439. \u0412\u0435\u0440\u0441\u0438\u044F \u043A\u043B\u0438\u0435\u043D\u0442\u0430 v1.0.", Item.PLAIN);//GEN-BEGIN:|170-getter|1|170-postInit
            stringItem4.setLayout(ImageItem.LAYOUT_CENTER | Item.LAYOUT_TOP | Item.LAYOUT_BOTTOM | Item.LAYOUT_VCENTER | ImageItem.LAYOUT_NEWLINE_BEFORE);
            stringItem4.setFont(getFont());//GEN-END:|170-getter|1|170-postInit

        }//GEN-BEGIN:|170-getter|2|
        return stringItem4;
    }
    //</editor-fold>//GEN-END:|170-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand1 ">//GEN-BEGIN:|201-getter|0|201-preInit
    /**
     * Returns an initiliazed instance of okCommand1 component.
     * @return the initialized component instance
     */
    public Command getOkCommand1() {
        if (okCommand1 == null) {//GEN-END:|201-getter|0|201-preInit

            okCommand1 = new Command("OK", Command.OK, 0);//GEN-LINE:|201-getter|1|201-postInit

        }//GEN-BEGIN:|201-getter|2|
        return okCommand1;
    }
    //</editor-fold>//GEN-END:|201-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand2 ">//GEN-BEGIN:|209-getter|0|209-preInit
    /**
     * Returns an initiliazed instance of okCommand2 component.
     * @return the initialized component instance
     */
    public Command getOkCommand2() {
        if (okCommand2 == null) {//GEN-END:|209-getter|0|209-preInit

            okCommand2 = new Command("OK", Command.OK, 3);//GEN-LINE:|209-getter|1|209-postInit

        }//GEN-BEGIN:|209-getter|2|
        return okCommand2;
    }
    //</editor-fold>//GEN-END:|209-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: list1 ">//GEN-BEGIN:|193-getter|0|193-preInit
    /**
     * Returns an initiliazed instance of list1 component.
     * @return the initialized component instance
     */
    public List getList1() {
        if (list1 == null) {//GEN-END:|193-getter|0|193-preInit

            list1 = new List("\u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0430", Choice.IMPLICIT);//GEN-BEGIN:|193-getter|1|193-postInit
            list1.append("\u0423\u0447\u0435\u0442\u043D\u0430\u044F \u0437\u0430\u043F\u0438\u0441\u044C", null);
            list1.append("\u041F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u0435", null);
            list1.append("\u0427\u0430\u0441\u043E\u0432\u043E\u0439 \u043F\u043E\u044F\u0441", null);
            list1.addCommand(getOkCommand1());
            list1.setCommandListener(this);
            list1.setSelectedFlags(new boolean[] { false, false, false });//GEN-END:|193-getter|1|193-postInit

        }//GEN-BEGIN:|193-getter|2|
        return list1;
    }
    //</editor-fold>//GEN-END:|193-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: list1Action ">//GEN-BEGIN:|193-action|0|193-preAction
    /**
     * Performs an action assigned to the selected list element in the list1 component.
     */
    public void list1Action() {//GEN-END:|193-action|0|193-preAction
        // enter pre-action user code here
        String __selectedString = getList1().getString(getList1().getSelectedIndex());//GEN-BEGIN:|193-action|1|196-preAction
        if (__selectedString != null) {
            if (__selectedString.equals("\u0423\u0447\u0435\u0442\u043D\u0430\u044F \u0437\u0430\u043F\u0438\u0441\u044C")) {//GEN-END:|193-action|1|196-preAction

                switchDisplayable(null, getForm3());//GEN-LINE:|193-action|2|196-postAction

                textField.setString(getUserName());
                textField1.setString(getUserPassword());
            } else if (__selectedString.equals("\u041F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u0435")) {//GEN-LINE:|193-action|3|197-preAction

                switchDisplayable(null, getForm4());//GEN-LINE:|193-action|4|197-postAction

                textField2.setString(getServerName());
                textField3.setString(getServerPort());
            } else if (__selectedString.equals("\u0427\u0430\u0441\u043E\u0432\u043E\u0439 \u043F\u043E\u044F\u0441")) {//GEN-LINE:|193-action|5|198-preAction

                switchDisplayable(null, getForm5());//GEN-LINE:|193-action|6|198-postAction

            }//GEN-BEGIN:|193-action|7|193-postAction
        }//GEN-END:|193-action|7|193-postAction
        // enter post-action user code here
    }//GEN-BEGIN:|193-action|8|
    //</editor-fold>//GEN-END:|193-action|8|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: form3 ">//GEN-BEGIN:|204-getter|0|204-preInit
    /**
     * Returns an initiliazed instance of form3 component.
     * @return the initialized component instance
     */
    public Form getForm3() {
        if (form3 == null) {//GEN-END:|204-getter|0|204-preInit

            form3 = new Form("\u0423\u0447\u0435\u0442\u043D\u0430\u044F \u0437\u0430\u043F\u0438\u0441\u044C", new Item[] { textField, getSpacer(), textField1 });//GEN-BEGIN:|204-getter|1|204-postInit
            form3.addCommand(getOkCommand2());
            form3.addCommand(getCancelCommand1());
            form3.addCommand(getItemCommand());
            form3.addCommand(getItemCommand1());
            form3.setCommandListener(this);//GEN-END:|204-getter|1|204-postInit

        }//GEN-BEGIN:|204-getter|2|
        return form3;
    }
    //</editor-fold>//GEN-END:|204-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: spacer ">//GEN-BEGIN:|206-getter|0|206-preInit
    /**
     * Returns an initiliazed instance of spacer component.
     * @return the initialized component instance
     */
    public Spacer getSpacer() {
        if (spacer == null) {//GEN-END:|206-getter|0|206-preInit

            spacer = new Spacer(16, 1);//GEN-LINE:|206-getter|1|206-postInit

        }//GEN-BEGIN:|206-getter|2|
        return spacer;
    }
    //</editor-fold>//GEN-END:|206-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand3 ">//GEN-BEGIN:|226-getter|0|226-preInit
    /**
     * Returns an initiliazed instance of okCommand3 component.
     * @return the initialized component instance
     */
    public Command getOkCommand3() {
        if (okCommand3 == null) {//GEN-END:|226-getter|0|226-preInit

            okCommand3 = new Command("OK", Command.OK, 0);//GEN-LINE:|226-getter|1|226-postInit

        }//GEN-BEGIN:|226-getter|2|
        return okCommand3;
    }
    //</editor-fold>//GEN-END:|226-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand4 ">//GEN-BEGIN:|237-getter|0|237-preInit
    /**
     * Returns an initiliazed instance of okCommand4 component.
     * @return the initialized component instance
     */
    public Command getOkCommand4() {
        if (okCommand4 == null) {//GEN-END:|237-getter|0|237-preInit

            okCommand4 = new Command("OK", Command.OK, 0);//GEN-LINE:|237-getter|1|237-postInit

        }//GEN-BEGIN:|237-getter|2|
        return okCommand4;
    }
    //</editor-fold>//GEN-END:|237-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand7 ">//GEN-BEGIN:|239-getter|0|239-preInit
    /**
     * Returns an initiliazed instance of backCommand7 component.
     * @return the initialized component instance
     */
    public Command getBackCommand7() {
        if (backCommand7 == null) {//GEN-END:|239-getter|0|239-preInit

            backCommand7 = new Command("\u041D\u0430\u0437\u0430\u0434", Command.BACK, 0);//GEN-LINE:|239-getter|1|239-postInit

        }//GEN-BEGIN:|239-getter|2|
        return backCommand7;
    }
    //</editor-fold>//GEN-END:|239-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand5 ">//GEN-BEGIN:|248-getter|0|248-preInit
    /**
     * Returns an initiliazed instance of okCommand5 component.
     * @return the initialized component instance
     */
    public Command getOkCommand5() {
        if (okCommand5 == null) {//GEN-END:|248-getter|0|248-preInit

            okCommand5 = new Command("OK", Command.OK, 0);//GEN-LINE:|248-getter|1|248-postInit

        }//GEN-BEGIN:|248-getter|2|
        return okCommand5;
    }
    //</editor-fold>//GEN-END:|248-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand8 ">//GEN-BEGIN:|250-getter|0|250-preInit
    /**
     * Returns an initiliazed instance of backCommand8 component.
     * @return the initialized component instance
     */
    public Command getBackCommand8() {
        if (backCommand8 == null) {//GEN-END:|250-getter|0|250-preInit

            backCommand8 = new Command("\u041D\u0430\u0437\u0430\u0434", Command.BACK, 0);//GEN-LINE:|250-getter|1|250-postInit

        }//GEN-BEGIN:|250-getter|2|
        return backCommand8;
    }
    //</editor-fold>//GEN-END:|250-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: form4 ">//GEN-BEGIN:|223-getter|0|223-preInit
    /**
     * Returns an initiliazed instance of form4 component.
     * @return the initialized component instance
     */
    public Form getForm4() {
        if (form4 == null) {//GEN-END:|223-getter|0|223-preInit

            form4 = new Form("\u041F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u0435", new Item[] { getTextField2(), getTextField3() });//GEN-BEGIN:|223-getter|1|223-postInit
            form4.addCommand(getOkCommand3());
            form4.addCommand(getCancelCommand());
            form4.setCommandListener(this);//GEN-END:|223-getter|1|223-postInit

        }//GEN-BEGIN:|223-getter|2|
        return form4;
    }
    //</editor-fold>//GEN-END:|223-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: textField2 ">//GEN-BEGIN:|224-getter|0|224-preInit
    /**
     * Returns an initiliazed instance of textField2 component.
     * @return the initialized component instance
     */
    public TextField getTextField2() {
        if (textField2 == null) {//GEN-END:|224-getter|0|224-preInit

            textField2 = new TextField("\u0421\u0435\u0440\u0432\u0435\u0440", null, 32, TextField.ANY);//GEN-LINE:|224-getter|1|224-postInit

        }//GEN-BEGIN:|224-getter|2|
        return textField2;
    }
    //</editor-fold>//GEN-END:|224-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: textField3 ">//GEN-BEGIN:|225-getter|0|225-preInit
    /**
     * Returns an initiliazed instance of textField3 component.
     * @return the initialized component instance
     */
    public TextField getTextField3() {
        if (textField3 == null) {//GEN-END:|225-getter|0|225-preInit

            textField3 = new TextField("\u041F\u043E\u0440\u0442", null, 32, TextField.ANY);//GEN-LINE:|225-getter|1|225-postInit

        }//GEN-BEGIN:|225-getter|2|
        return textField3;
    }
    //</editor-fold>//GEN-END:|225-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: form5 ">//GEN-BEGIN:|236-getter|0|236-preInit
    /**
     * Returns an initiliazed instance of form5 component.
     * @return the initialized component instance
     */
    public Form getForm5() {
        if (form5 == null) {//GEN-END:|236-getter|0|236-preInit

            form5 = new Form("\u0427\u0430\u0441\u043E\u0432\u043E\u0439 \u043F\u043E\u044F\u0441", new Item[] { getChoiceGroup() });//GEN-BEGIN:|236-getter|1|236-postInit
            form5.addCommand(getOkCommand4());
            form5.addCommand(getBackCommand7());
            form5.setCommandListener(this);//GEN-END:|236-getter|1|236-postInit

        }//GEN-BEGIN:|236-getter|2|
        return form5;
    }
    //</editor-fold>//GEN-END:|236-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: choiceGroup ">//GEN-BEGIN:|259-getter|0|259-preInit
    /**
     * Returns an initiliazed instance of choiceGroup component.
     * @return the initialized component instance
     */
    public ChoiceGroup getChoiceGroup() {
        if (choiceGroup == null) {//GEN-END:|259-getter|0|259-preInit

            choiceGroup = new ChoiceGroup("\u0427\u0430\u0441\u043E\u0432\u043E\u0439 \u043F\u043E\u044F\u0441", Choice.EXCLUSIVE);//GEN-BEGIN:|259-getter|1|259-postInit
            choiceGroup.append("GMT -12:00", null);
            choiceGroup.append("GMT -11:00", null);
            choiceGroup.append("GMT -10:00", null);
            choiceGroup.append("GMT -9:00", null);
            choiceGroup.append("GMT -8:00", null);
            choiceGroup.append("GMT -7:00", null);
            choiceGroup.append("GMT -6:00", null);
            choiceGroup.append("GMT -5:00", null);
            choiceGroup.append("GMT -4:00", null);
            choiceGroup.append("GMT -3:00", null);
            choiceGroup.append("GMT -2:00", null);
            choiceGroup.append("GMT -1:00", null);
            choiceGroup.append("GMT 0:00", null);
            choiceGroup.append("GMT +1:00", null);
            choiceGroup.append("GMT +2:00", null);
            choiceGroup.append("GMT +3:00", null);
            choiceGroup.append("GMT +4:00", null);
            choiceGroup.append("GMT +5:00", null);
            choiceGroup.append("GMT +6:00", null);
            choiceGroup.append("GMT +7:00", null);
            choiceGroup.append("GMT +8:00", null);
            choiceGroup.append("GMT +9:00", null);
            choiceGroup.append("GMT +10:00", null);
            choiceGroup.append("GMT +11:00", null);
            choiceGroup.setLayout(ImageItem.LAYOUT_DEFAULT);
            choiceGroup.setFitPolicy(Choice.TEXT_WRAP_OFF);
            choiceGroup.setSelectedFlags(new boolean[] { false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false });
            choiceGroup.setPreferredSize(-1, -1);//GEN-END:|259-getter|1|259-postInit

        }//GEN-BEGIN:|259-getter|2|
        return choiceGroup;
    }
    //</editor-fold>//GEN-END:|259-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: font ">//GEN-BEGIN:|289-getter|0|289-preInit
    /**
     * Returns an initiliazed instance of font component.
     * @return the initialized component instance
     */
    public Font getFont() {
        if (font == null) {//GEN-END:|289-getter|0|289-preInit

            font = Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_PLAIN, Font.SIZE_MEDIUM);//GEN-LINE:|289-getter|1|289-postInit

        }//GEN-BEGIN:|289-getter|2|
        return font;
    }
    //</editor-fold>//GEN-END:|289-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: list2 ">//GEN-BEGIN:|311-getter|0|311-preInit
    /**
     * Returns an initiliazed instance of list2 component.
     * @return the initialized component instance
     */
    public List getList2() {
        if (list2 == null) {//GEN-END:|311-getter|0|311-preInit

            list2 = new List("\u0421\u043F\u0438\u0441\u043E\u043A \u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u0435\u043B\u0435\u0439", Choice.IMPLICIT);//GEN-BEGIN:|311-getter|1|311-postInit
            list2.addCommand(getOkCommand6());
            list2.addCommand(getBackCommand9());
            list2.addCommand(getItemCommand2());
            list2.setCommandListener(this);//GEN-END:|311-getter|1|311-postInit

        }//GEN-BEGIN:|311-getter|2|
        return list2;
    }
    //</editor-fold>//GEN-END:|311-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: list2Action ">//GEN-BEGIN:|311-action|0|311-preAction
    /**
     * Performs an action assigned to the selected list element in the list2 component.
     */
    public void list2Action() {//GEN-END:|311-action|0|311-preAction

        String __selectedString = getList2().getString(getList2().getSelectedIndex());//GEN-LINE:|311-action|1|311-postAction
        if (__selectedString != null) {
            switchDisplayable(null, getList3());
            list3.setTitle("Меню абонента" + " " + __selectedString);

        }//GEN-BEGIN:|311-action|2|
        //</editor-fold>//GEN-END:|311-action|2|
}

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand6 ">//GEN-BEGIN:|315-getter|0|315-preInit
    /**
     * Returns an initiliazed instance of okCommand6 component.
     * @return the initialized component instance
     */
    public Command getOkCommand6() {
        if (okCommand6 == null) {//GEN-END:|315-getter|0|315-preInit

            okCommand6 = new Command("OK", Command.OK, 0);//GEN-LINE:|315-getter|1|315-postInit

        }//GEN-BEGIN:|315-getter|2|
        return okCommand6;
    }
    //</editor-fold>//GEN-END:|315-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand9 ">//GEN-BEGIN:|318-getter|0|318-preInit
    /**
     * Returns an initiliazed instance of backCommand9 component.
     * @return the initialized component instance
     */
    public Command getBackCommand9() {
        if (backCommand9 == null) {//GEN-END:|318-getter|0|318-preInit

            backCommand9 = new Command("\u041D\u0430\u0437\u0430\u0434", Command.BACK, 0);//GEN-LINE:|318-getter|1|318-postInit

        }//GEN-BEGIN:|318-getter|2|
        return backCommand9;
    }
    //</editor-fold>//GEN-END:|318-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: cancelCommand ">//GEN-BEGIN:|321-getter|0|321-preInit
    /**
     * Returns an initiliazed instance of cancelCommand component.
     * @return the initialized component instance
     */
    public Command getCancelCommand() {
        if (cancelCommand == null) {//GEN-END:|321-getter|0|321-preInit

            cancelCommand = new Command("\u041E\u0442\u043C\u0435\u043D\u0430", Command.CANCEL, 0);//GEN-LINE:|321-getter|1|321-postInit

        }//GEN-BEGIN:|321-getter|2|
        return cancelCommand;
    }
    //</editor-fold>//GEN-END:|321-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: cancelCommand1 ">//GEN-BEGIN:|324-getter|0|324-preInit
    /**
     * Returns an initiliazed instance of cancelCommand1 component.
     * @return the initialized component instance
     */
    public Command getCancelCommand1() {
        if (cancelCommand1 == null) {//GEN-END:|324-getter|0|324-preInit

            cancelCommand1 = new Command("\u041E\u0442\u043C\u0435\u043D\u0430", Command.CANCEL, 0);//GEN-LINE:|324-getter|1|324-postInit

        }//GEN-BEGIN:|324-getter|2|
        return cancelCommand1;
    }
    //</editor-fold>//GEN-END:|324-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand7 ">//GEN-BEGIN:|329-getter|0|329-preInit
    /**
     * Returns an initiliazed instance of okCommand7 component.
     * @return the initialized component instance
     */
    public Command getOkCommand7() {
        if (okCommand7 == null) {//GEN-END:|329-getter|0|329-preInit

            okCommand7 = new Command("OK", Command.OK, 0);//GEN-LINE:|329-getter|1|329-postInit

        }//GEN-BEGIN:|329-getter|2|
        return okCommand7;
    }
    //</editor-fold>//GEN-END:|329-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: cancelCommand2 ">//GEN-BEGIN:|331-getter|0|331-preInit
    /**
     * Returns an initiliazed instance of cancelCommand2 component.
     * @return the initialized component instance
     */
    public Command getCancelCommand2() {
        if (cancelCommand2 == null) {//GEN-END:|331-getter|0|331-preInit

            cancelCommand2 = new Command("\u041E\u0442\u043C\u0435\u043D\u0430", Command.CANCEL, 0);//GEN-LINE:|331-getter|1|331-postInit

        }//GEN-BEGIN:|331-getter|2|
        return cancelCommand2;
    }
    //</editor-fold>//GEN-END:|331-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: form7 ">//GEN-BEGIN:|327-getter|0|327-preInit
    /**
     * Returns an initiliazed instance of form7 component.
     * @return the initialized component instance
     */
    public Form getForm7() {
        if (form7 == null) {//GEN-END:|327-getter|0|327-preInit

            form7 = new Form("\u0421\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u0435", new Item[] { getTextField7(), getTextField4() });//GEN-BEGIN:|327-getter|1|327-postInit
            form7.addCommand(getOkCommand7());
            form7.addCommand(getCancelCommand2());
            form7.setCommandListener(this);//GEN-END:|327-getter|1|327-postInit

        }//GEN-BEGIN:|327-getter|2|
        return form7;
    }
    //</editor-fold>//GEN-END:|327-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: textField4 ">//GEN-BEGIN:|328-getter|0|328-preInit
    /**
     * Returns an initiliazed instance of textField4 component.
     * @return the initialized component instance
     */
    public TextField getTextField4() {
        if (textField4 == null) {//GEN-END:|328-getter|0|328-preInit

            textField4 = new TextField("\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0441\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u0435", null, 32, TextField.ANY);//GEN-LINE:|328-getter|1|328-postInit

        }//GEN-BEGIN:|328-getter|2|
        return textField4;
    }
    //</editor-fold>//GEN-END:|328-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand10 ">//GEN-BEGIN:|336-getter|0|336-preInit
    /**
     * Returns an initiliazed instance of backCommand10 component.
     * @return the initialized component instance
     */
    public Command getBackCommand10() {
        if (backCommand10 == null) {//GEN-END:|336-getter|0|336-preInit

            backCommand10 = new Command("\u041D\u0430\u0437\u0430\u0434", Command.BACK, 0);//GEN-LINE:|336-getter|1|336-postInit

        }//GEN-BEGIN:|336-getter|2|
        return backCommand10;
    }
    //</editor-fold>//GEN-END:|336-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand11 ">//GEN-BEGIN:|349-getter|0|349-preInit
    /**
     * Returns an initiliazed instance of backCommand11 component.
     * @return the initialized component instance
     */
    public Command getBackCommand11() {
        if (backCommand11 == null) {//GEN-END:|349-getter|0|349-preInit

            backCommand11 = new Command("\u041D\u0430\u0437\u0430\u0434", Command.BACK, 0);//GEN-LINE:|349-getter|1|349-postInit

        }//GEN-BEGIN:|349-getter|2|
        return backCommand11;
    }
    //</editor-fold>//GEN-END:|349-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: form8 ">//GEN-BEGIN:|335-getter|0|335-preInit
    /**
     * Returns an initiliazed instance of form8 component.
     * @return the initialized component instance
     */
    public Form getForm8() {
        if (form8 == null) {//GEN-END:|335-getter|0|335-preInit

            form8 = new Form("\u0418\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044F \u043E \u043A\u043E\u043D\u0442\u0430\u043A\u0442\u0435", new Item[] { getStringItem5(), getStringItem1(), getStringItem15(), getStringItem6(), getStringItem7(), getStringItem2(), getStringItem9(), getStringItem10(), getStringItem11(), getStringItem13(), getStringItem14(), getStringItem12(), getStringItem16(), getStringItem17(), getStringItem18() });//GEN-BEGIN:|335-getter|1|335-postInit
            form8.addCommand(getBackCommand10());
            form8.setCommandListener(this);//GEN-END:|335-getter|1|335-postInit
            initial = true;
        }//GEN-BEGIN:|335-getter|2|
        return form8;
    }
    //</editor-fold>//GEN-END:|335-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem5 ">//GEN-BEGIN:|339-getter|0|339-preInit
    /**
     * Returns an initiliazed instance of stringItem5 component.
     * @return the initialized component instance
     */
    public StringItem getStringItem5() {
        if (stringItem5 == null) {//GEN-END:|339-getter|0|339-preInit

            stringItem5 = new StringItem("\u0424\u0430\u043C\u0438\u043B\u0438\u044F", null);//GEN-LINE:|339-getter|1|339-postInit

        }//GEN-BEGIN:|339-getter|2|
        return stringItem5;
    }
    //</editor-fold>//GEN-END:|339-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem6 ">//GEN-BEGIN:|341-getter|0|341-preInit
    /**
     * Returns an initiliazed instance of stringItem6 component.
     * @return the initialized component instance
     */
    public StringItem getStringItem6() {
        if (stringItem6 == null) {//GEN-END:|341-getter|0|341-preInit

            stringItem6 = new StringItem("\u0414\u0430\u0442\u0430 \u0440\u043E\u0436\u0434\u0435\u043D\u0438\u044F", null);//GEN-LINE:|341-getter|1|341-postInit

        }//GEN-BEGIN:|341-getter|2|
        return stringItem6;
    }
    //</editor-fold>//GEN-END:|341-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem7 ">//GEN-BEGIN:|342-getter|0|342-preInit
    /**
     * Returns an initiliazed instance of stringItem7 component.
     * @return the initialized component instance
     */
    public StringItem getStringItem7() {
        if (stringItem7 == null) {//GEN-END:|342-getter|0|342-preInit

            stringItem7 = new StringItem("\u0411\u0438\u043E\u0433\u0440\u0430\u0444\u0438\u044F", null, Item.PLAIN);//GEN-LINE:|342-getter|1|342-postInit

        }//GEN-BEGIN:|342-getter|2|
        return stringItem7;
    }
    //</editor-fold>//GEN-END:|342-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: list3 ">//GEN-BEGIN:|344-getter|0|344-preInit
    /**
     * Returns an initiliazed instance of list3 component.
     * @return the initialized component instance
     */
    public List getList3() {
        if (list3 == null) {//GEN-END:|344-getter|0|344-preInit

            list3 = new List("\u041C\u0435\u043D\u044E \u043A\u043E\u043D\u0442\u0430\u043A\u0442\u0430", Choice.IMPLICIT);//GEN-BEGIN:|344-getter|1|344-postInit
            list3.append("\u041E\u0442\u043F\u0440\u0430\u0432\u043A\u0430 \u0441\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u044F", null);
            list3.append("\u0418\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044F \u043E \u043A\u043E\u043D\u0442\u0430\u043A\u0442\u0435", null);
            list3.addCommand(getBackCommand11());
            list3.setCommandListener(this);
            list3.setSelectedFlags(new boolean[] { false, false });//GEN-END:|344-getter|1|344-postInit

        }//GEN-BEGIN:|344-getter|2|
        return list3;
    }
    //</editor-fold>//GEN-END:|344-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: list3Action ">//GEN-BEGIN:|344-action|0|344-preAction
    /**
     * Performs an action assigned to the selected list element in the list3 component.
     */
    public void list3Action() {//GEN-END:|344-action|0|344-preAction

        String __selectedString = getList3().getString(getList3().getSelectedIndex());//GEN-BEGIN:|344-action|1|347-preAction
        if (__selectedString != null) {
            if (__selectedString.equals("\u041E\u0442\u043F\u0440\u0430\u0432\u043A\u0430 \u0441\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u044F")) {//GEN-END:|344-action|1|347-preAction

                switchDisplayable(null, getForm7());//GEN-LINE:|344-action|2|347-postAction

            } else if (__selectedString.equals("\u0418\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044F \u043E \u043A\u043E\u043D\u0442\u0430\u043A\u0442\u0435")) {//GEN-LINE:|344-action|3|348-preAction

                switchDisplayable(null, getForm8());//GEN-LINE:|344-action|4|348-postAction
                try {
                    getInfoUser(getXMLInfoForeignUser(UserData.getId()), 0);
                } catch (IOException ex) {
                }
            }//GEN-BEGIN:|344-action|5|344-postAction
        }//GEN-END:|344-action|5|344-postAction

    }//GEN-BEGIN:|344-action|6|
    //</editor-fold>//GEN-END:|344-action|6|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: ticker ">//GEN-BEGIN:|356-getter|0|356-preInit
    /**
     * Returns an initiliazed instance of ticker component.
     * @return the initialized component instance
     */
    public Ticker getTicker() {
        if (ticker == null) {//GEN-END:|356-getter|0|356-preInit

            ticker = new Ticker("");//GEN-LINE:|356-getter|1|356-postInit

        }//GEN-BEGIN:|356-getter|2|
        return ticker;
    }
    //</editor-fold>//GEN-END:|356-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem1 ">//GEN-BEGIN:|359-getter|0|359-preInit
    /**
     * Returns an initiliazed instance of stringItem1 component.
     * @return the initialized component instance
     */
    public StringItem getStringItem1() {
        if (stringItem1 == null) {//GEN-END:|359-getter|0|359-preInit

            stringItem1 = new StringItem("\u0418\u043C\u044F", null);//GEN-LINE:|359-getter|1|359-postInit

        }//GEN-BEGIN:|359-getter|2|
        return stringItem1;
    }
    //</editor-fold>//GEN-END:|359-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem2 ">//GEN-BEGIN:|360-getter|0|360-preInit
    /**
     * Returns an initiliazed instance of stringItem2 component.
     * @return the initialized component instance
     */
    public StringItem getStringItem2() {
        if (stringItem2 == null) {//GEN-END:|360-getter|0|360-preInit

            stringItem2 = new StringItem("\u0426\u0432\u0435\u0442 \u0432\u043E\u043B\u043E\u0441", null);//GEN-LINE:|360-getter|1|360-postInit

        }//GEN-BEGIN:|360-getter|2|
        return stringItem2;
    }
    //</editor-fold>//GEN-END:|360-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem9 ">//GEN-BEGIN:|361-getter|0|361-preInit
    /**
     * Returns an initiliazed instance of stringItem9 component.
     * @return the initialized component instance
     */
    public StringItem getStringItem9() {
        if (stringItem9 == null) {//GEN-END:|361-getter|0|361-preInit

            stringItem9 = new StringItem("\u0426\u0432\u0435\u0442 \u0433\u043B\u0430\u0437", null);//GEN-LINE:|361-getter|1|361-postInit

        }//GEN-BEGIN:|361-getter|2|
        return stringItem9;
    }
    //</editor-fold>//GEN-END:|361-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem10 ">//GEN-BEGIN:|362-getter|0|362-preInit
    /**
     * Returns an initiliazed instance of stringItem10 component.
     * @return the initialized component instance
     */
    public StringItem getStringItem10() {
        if (stringItem10 == null) {//GEN-END:|362-getter|0|362-preInit

            stringItem10 = new StringItem("\u041E\u0441\u043D\u043E\u0432\u043D\u043E\u0439 \u0440\u0430\u0437\u043C\u0435\u0440", null);//GEN-LINE:|362-getter|1|362-postInit

        }//GEN-BEGIN:|362-getter|2|
        return stringItem10;
    }
    //</editor-fold>//GEN-END:|362-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem11 ">//GEN-BEGIN:|363-getter|0|363-preInit
    /**
     * Returns an initiliazed instance of stringItem11 component.
     * @return the initialized component instance
     */
    public StringItem getStringItem11() {
        if (stringItem11 == null) {//GEN-END:|363-getter|0|363-preInit

            stringItem11 = new StringItem("\u0417\u043D\u0430\u043A \u0437\u043E\u0434\u0438\u0430\u043A\u0430", null);//GEN-LINE:|363-getter|1|363-postInit

        }//GEN-BEGIN:|363-getter|2|
        return stringItem11;
    }
    //</editor-fold>//GEN-END:|363-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem12 ">//GEN-BEGIN:|364-getter|0|364-preInit
    /**
     * Returns an initiliazed instance of stringItem12 component.
     * @return the initialized component instance
     */
    public StringItem getStringItem12() {
        if (stringItem12 == null) {//GEN-END:|364-getter|0|364-preInit

            stringItem12 = new StringItem("\u041E\u0440\u0438\u0435\u043D\u0442\u0430\u0446\u0438\u044F", null);//GEN-LINE:|364-getter|1|364-postInit

        }//GEN-BEGIN:|364-getter|2|
        return stringItem12;
    }
    //</editor-fold>//GEN-END:|364-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem13 ">//GEN-BEGIN:|365-getter|0|365-preInit
    /**
     * Returns an initiliazed instance of stringItem13 component.
     * @return the initialized component instance
     */
    public StringItem getStringItem13() {
        if (stringItem13 == null) {//GEN-END:|365-getter|0|365-preInit

            stringItem13 = new StringItem("\u0426\u0435\u043B\u0438", null);//GEN-LINE:|365-getter|1|365-postInit

        }//GEN-BEGIN:|365-getter|2|
        return stringItem13;
    }
    //</editor-fold>//GEN-END:|365-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem14 ">//GEN-BEGIN:|366-getter|0|366-preInit
    /**
     * Returns an initiliazed instance of stringItem14 component.
     * @return the initialized component instance
     */
    public StringItem getStringItem14() {
        if (stringItem14 == null) {//GEN-END:|366-getter|0|366-preInit

            stringItem14 = new StringItem("\u0418\u043D\u0442\u0435\u0440\u0435\u0441\u044B", null);//GEN-LINE:|366-getter|1|366-postInit

        }//GEN-BEGIN:|366-getter|2|
        return stringItem14;
    }
    //</editor-fold>//GEN-END:|366-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem15 ">//GEN-BEGIN:|367-getter|0|367-preInit
    /**
     * Returns an initiliazed instance of stringItem15 component.
     * @return the initialized component instance
     */
    public StringItem getStringItem15() {
        if (stringItem15 == null) {//GEN-END:|367-getter|0|367-preInit

            stringItem15 = new StringItem("\u041F\u043E\u043B", null);//GEN-LINE:|367-getter|1|367-postInit

        }//GEN-BEGIN:|367-getter|2|
        return stringItem15;
    }
    //</editor-fold>//GEN-END:|367-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem16 ">//GEN-BEGIN:|368-getter|0|368-preInit
    /**
     * Returns an initiliazed instance of stringItem16 component.
     * @return the initialized component instance
     */
    public StringItem getStringItem16() {
        if (stringItem16 == null) {//GEN-END:|368-getter|0|368-preInit

            stringItem16 = new StringItem("\u041D\u043E\u043C\u0435\u0440 \u0442\u0435\u043B\u0435\u0444\u043E\u043D\u0430", null);//GEN-LINE:|368-getter|1|368-postInit

        }//GEN-BEGIN:|368-getter|2|
        return stringItem16;
    }
    //</editor-fold>//GEN-END:|368-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem17 ">//GEN-BEGIN:|369-getter|0|369-preInit
    /**
     * Returns an initiliazed instance of stringItem17 component.
     * @return the initialized component instance
     */
    public StringItem getStringItem17() {
        if (stringItem17 == null) {//GEN-END:|369-getter|0|369-preInit

            stringItem17 = new StringItem("ICQ", null);//GEN-LINE:|369-getter|1|369-postInit

        }//GEN-BEGIN:|369-getter|2|
        return stringItem17;
    }
    //</editor-fold>//GEN-END:|369-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem18 ">//GEN-BEGIN:|370-getter|0|370-preInit
    /**
     * Returns an initiliazed instance of stringItem18 component.
     * @return the initialized component instance
     */
    public StringItem getStringItem18() {
        if (stringItem18 == null) {//GEN-END:|370-getter|0|370-preInit

            stringItem18 = new StringItem("Jabber", null);//GEN-LINE:|370-getter|1|370-postInit

        }//GEN-BEGIN:|370-getter|2|
        return stringItem18;
    }
    //</editor-fold>//GEN-END:|370-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: itemCommand ">//GEN-BEGIN:|371-getter|0|371-preInit
    /**
     * Returns an initiliazed instance of itemCommand component.
     * @return the initialized component instance
     */
    public Command getItemCommand() {
        if (itemCommand == null) {//GEN-END:|371-getter|0|371-preInit
            // write pre-init user code here
            itemCommand = new Command("\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044F", Command.ITEM, 1);//GEN-LINE:|371-getter|1|371-postInit
            // write post-init user code here
        }//GEN-BEGIN:|371-getter|2|
        return itemCommand;
    }
    //</editor-fold>//GEN-END:|371-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand ">//GEN-BEGIN:|384-getter|0|384-preInit
    /**
     * Returns an initiliazed instance of okCommand component.
     * @return the initialized component instance
     */
    public Command getOkCommand() {
        if (okCommand == null) {//GEN-END:|384-getter|0|384-preInit
            // write pre-init user code here
            okCommand = new Command("OK", Command.OK, 0);//GEN-LINE:|384-getter|1|384-postInit
            // write post-init user code here
        }//GEN-BEGIN:|384-getter|2|
        return okCommand;
    }
    //</editor-fold>//GEN-END:|384-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand ">//GEN-BEGIN:|386-getter|0|386-preInit
    /**
     * Returns an initiliazed instance of backCommand component.
     * @return the initialized component instance
     */
    public Command getBackCommand() {
        if (backCommand == null) {//GEN-END:|386-getter|0|386-preInit
            // write pre-init user code here
            backCommand = new Command("\u041D\u0430\u0437\u0430\u0434", Command.BACK, 0);//GEN-LINE:|386-getter|1|386-postInit
            // write post-init user code here
        }//GEN-BEGIN:|386-getter|2|
        return backCommand;
    }
    //</editor-fold>//GEN-END:|386-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: form ">//GEN-BEGIN:|381-getter|0|381-preInit
    /**
     * Returns an initiliazed instance of form component.
     * @return the initialized component instance
     */
    public Form getForm() {
        if (form == null) {//GEN-END:|381-getter|0|381-preInit
            // write pre-init user code here
            form = new Form("\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044F", new Item[] { getTextField5(), getTextField6() });//GEN-BEGIN:|381-getter|1|381-postInit
            form.addCommand(getOkCommand());
            form.addCommand(getBackCommand());
            form.setCommandListener(this);//GEN-END:|381-getter|1|381-postInit
            // write post-init user code here
        }//GEN-BEGIN:|381-getter|2|
        return form;
    }
    //</editor-fold>//GEN-END:|381-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: textField5 ">//GEN-BEGIN:|382-getter|0|382-preInit
    /**
     * Returns an initiliazed instance of textField5 component.
     * @return the initialized component instance
     */
    public TextField getTextField5() {
        if (textField5 == null) {//GEN-END:|382-getter|0|382-preInit
            // write pre-init user code here
            textField5 = new TextField("E-mail", null, 32, TextField.EMAILADDR);//GEN-LINE:|382-getter|1|382-postInit
            // write post-init user code here
        }//GEN-BEGIN:|382-getter|2|
        return textField5;
    }
    //</editor-fold>//GEN-END:|382-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: textField6 ">//GEN-BEGIN:|383-getter|0|383-preInit
    /**
     * Returns an initiliazed instance of textField6 component.
     * @return the initialized component instance
     */
    public TextField getTextField6() {
        if (textField6 == null) {//GEN-END:|383-getter|0|383-preInit
            // write pre-init user code here
            textField6 = new TextField("Password", null, 32, TextField.ANY | TextField.PASSWORD);//GEN-LINE:|383-getter|1|383-postInit
            // write post-init user code here
        }//GEN-BEGIN:|383-getter|2|
        return textField6;
    }
    //</editor-fold>//GEN-END:|383-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: task ">//GEN-BEGIN:|378-getter|0|378-preInit
    /**
     * Returns an initiliazed instance of task component.
     * @return the initialized component instance
     */
    public SimpleCancellableTask getTask() {
        if (task == null) {//GEN-END:|378-getter|0|378-preInit
            // write pre-init user code here
            task = new SimpleCancellableTask();//GEN-BEGIN:|378-getter|1|378-execute
            task.setExecutable(new org.netbeans.microedition.util.Executable() {
                public void execute() throws Exception {//GEN-END:|378-getter|1|378-execute
                    // write task-execution user code here
                }//GEN-BEGIN:|378-getter|2|378-postInit
            });//GEN-END:|378-getter|2|378-postInit
            // write post-init user code here
        }//GEN-BEGIN:|378-getter|3|
        return task;
    }
    //</editor-fold>//GEN-END:|378-getter|3|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: itemCommand1 ">//GEN-BEGIN:|392-getter|0|392-preInit
    /**
     * Returns an initiliazed instance of itemCommand1 component.
     * @return the initialized component instance
     */
    public Command getItemCommand1() {
        if (itemCommand1 == null) {//GEN-END:|392-getter|0|392-preInit
            // write pre-init user code here
            itemCommand1 = new Command("\u0423\u0434\u0430\u043B\u0435\u043D\u0438\u0435", Command.ITEM, 2);//GEN-LINE:|392-getter|1|392-postInit
            // write post-init user code here
        }//GEN-BEGIN:|392-getter|2|
        return itemCommand1;
    }
    //</editor-fold>//GEN-END:|392-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: alert ">//GEN-BEGIN:|394-getter|0|394-preInit
    /**
     * Returns an initiliazed instance of alert component.
     * @return the initialized component instance
     */
    public Alert getAlert() {
        if (alert == null) {//GEN-END:|394-getter|0|394-preInit
            // write pre-init user code here
            alert = new Alert("\u041E\u0448\u0438\u0431\u043A\u0430", "", null, null);//GEN-BEGIN:|394-getter|1|394-postInit
            alert.addCommand(getBackCommand1());
            alert.setCommandListener(this);
            alert.setTimeout(Alert.FOREVER);//GEN-END:|394-getter|1|394-postInit
            // write post-init user code here
        }//GEN-BEGIN:|394-getter|2|
        return alert;
    }
    //</editor-fold>//GEN-END:|394-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand1 ">//GEN-BEGIN:|395-getter|0|395-preInit
    /**
     * Returns an initiliazed instance of backCommand1 component.
     * @return the initialized component instance
     */
    public Command getBackCommand1() {
        if (backCommand1 == null) {//GEN-END:|395-getter|0|395-preInit
            // write pre-init user code here
            backCommand1 = new Command("\u041D\u0430\u0437\u0430\u0434", Command.BACK, 0);//GEN-LINE:|395-getter|1|395-postInit
            // write post-init user code here
        }//GEN-BEGIN:|395-getter|2|
        return backCommand1;
    }
    //</editor-fold>//GEN-END:|395-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand2 ">//GEN-BEGIN:|399-getter|0|399-preInit
    /**
     * Returns an initiliazed instance of backCommand2 component.
     * @return the initialized component instance
     */
    public Command getBackCommand2() {
        if (backCommand2 == null) {//GEN-END:|399-getter|0|399-preInit
            // write pre-init user code here
            backCommand2 = new Command("\u041D\u0430\u0437\u0430\u0434", Command.BACK, 0);//GEN-LINE:|399-getter|1|399-postInit
            // write post-init user code here
        }//GEN-BEGIN:|399-getter|2|
        return backCommand2;
    }
    //</editor-fold>//GEN-END:|399-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: alert1 ">//GEN-BEGIN:|398-getter|0|398-preInit
    /**
     * Returns an initiliazed instance of alert1 component.
     * @return the initialized component instance
     */
    public Alert getAlert1() {
        if (alert1 == null) {//GEN-END:|398-getter|0|398-preInit
            // write pre-init user code here
            alert1 = new Alert("\u041E\u0448\u0438\u0431\u043A\u0430");//GEN-BEGIN:|398-getter|1|398-postInit
            alert1.addCommand(getBackCommand2());
            alert1.setCommandListener(this);
            alert1.setTimeout(Alert.FOREVER);//GEN-END:|398-getter|1|398-postInit
            // write post-init user code here
        }//GEN-BEGIN:|398-getter|2|
        return alert1;
    }
    //</editor-fold>//GEN-END:|398-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: itemCommand2 ">//GEN-BEGIN:|402-getter|0|402-preInit
    /**
     * Returns an initiliazed instance of itemCommand2 component.
     * @return the initialized component instance
     */
    public Command getItemCommand2() {
        if (itemCommand2 == null) {//GEN-END:|402-getter|0|402-preInit
            // write pre-init user code here
            itemCommand2 = new Command("\u041B\u0438\u0447\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435", Command.ITEM, 0);//GEN-LINE:|402-getter|1|402-postInit
            // write post-init user code here
        }//GEN-BEGIN:|402-getter|2|
        return itemCommand2;
    }
    //</editor-fold>//GEN-END:|402-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: cancelCommand3 ">//GEN-BEGIN:|413-getter|0|413-preInit
    /**
     * Returns an initiliazed instance of cancelCommand3 component.
     * @return the initialized component instance
     */
    public Command getCancelCommand3() {
        if (cancelCommand3 == null) {//GEN-END:|413-getter|0|413-preInit
            // write pre-init user code here
            cancelCommand3 = new Command("\u041E\u0442\u043C\u0435\u043D\u0430", Command.CANCEL, 0);//GEN-LINE:|413-getter|1|413-postInit
            // write post-init user code here
        }//GEN-BEGIN:|413-getter|2|
        return cancelCommand3;
    }
    //</editor-fold>//GEN-END:|413-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: itemCommand3 ">//GEN-BEGIN:|415-getter|0|415-preInit
    /**
     * Returns an initiliazed instance of itemCommand3 component.
     * @return the initialized component instance
     */
    public Command getItemCommand3() {
        if (itemCommand3 == null) {//GEN-END:|415-getter|0|415-preInit
            // write pre-init user code here
            itemCommand3 = new Command("\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C", Command.ITEM, 0);//GEN-LINE:|415-getter|1|415-postInit
            // write post-init user code here
        }//GEN-BEGIN:|415-getter|2|
        return itemCommand3;
    }
    //</editor-fold>//GEN-END:|415-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: alert2 ">//GEN-BEGIN:|437-getter|0|437-preInit
    /**
     * Returns an initiliazed instance of alert2 component.
     * @return the initialized component instance
     */
    public Alert getAlert2() {
        if (alert2 == null) {//GEN-END:|437-getter|0|437-preInit
            // write pre-init user code here
            alert2 = new Alert("alert2");//GEN-BEGIN:|437-getter|1|437-postInit
            alert2.addCommand(getBackCommand6());
            alert2.setCommandListener(this);
            alert2.setTimeout(Alert.FOREVER);//GEN-END:|437-getter|1|437-postInit
            // write post-init user code here
        }//GEN-BEGIN:|437-getter|2|
        return alert2;
    }
    //</editor-fold>//GEN-END:|437-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand6 ">//GEN-BEGIN:|438-getter|0|438-preInit
    /**
     * Returns an initiliazed instance of backCommand6 component.
     * @return the initialized component instance
     */
    public Command getBackCommand6() {
        if (backCommand6 == null) {//GEN-END:|438-getter|0|438-preInit
            // write pre-init user code here
            backCommand6 = new Command("\u041D\u0430\u0437\u0430\u0434", Command.BACK, 0);//GEN-LINE:|438-getter|1|438-postInit
            // write post-init user code here
        }//GEN-BEGIN:|438-getter|2|
        return backCommand6;
    }
    //</editor-fold>//GEN-END:|438-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: cancelCommand4 ">//GEN-BEGIN:|442-getter|0|442-preInit
    /**
     * Returns an initiliazed instance of cancelCommand4 component.
     * @return the initialized component instance
     */
    public Command getCancelCommand4() {
        if (cancelCommand4 == null) {//GEN-END:|442-getter|0|442-preInit
            // write pre-init user code here
            cancelCommand4 = new Command("\u041E\u0442\u043C\u0435\u043D\u0430", Command.CANCEL, 0);//GEN-LINE:|442-getter|1|442-postInit
            // write post-init user code here
        }//GEN-BEGIN:|442-getter|2|
        return cancelCommand4;
    }
    //</editor-fold>//GEN-END:|442-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: itemCommand4 ">//GEN-BEGIN:|444-getter|0|444-preInit
    /**
     * Returns an initiliazed instance of itemCommand4 component.
     * @return the initialized component instance
     */
    public Command getItemCommand4() {
        if (itemCommand4 == null) {//GEN-END:|444-getter|0|444-preInit
            // write pre-init user code here
            itemCommand4 = new Command("\u0414\u0430", Command.ITEM, 0);//GEN-LINE:|444-getter|1|444-postInit
            // write post-init user code here
        }//GEN-BEGIN:|444-getter|2|
        return itemCommand4;
    }
    //</editor-fold>//GEN-END:|444-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: form6 ">//GEN-BEGIN:|441-getter|0|441-preInit
    /**
     * Returns an initiliazed instance of form6 component.
     * @return the initialized component instance
     */
    public Form getForm6() {
        if (form6 == null) {//GEN-END:|441-getter|0|441-preInit
            // write pre-init user code here
            form6 = new Form("\u0423\u0434\u0430\u043B\u0435\u043D\u0438\u0435 \u0443\u0447\u0435\u0442\u043D\u043E\u0439 \u0437\u0430\u043F\u0438\u0441\u0438", new Item[] { getTextField22() });//GEN-BEGIN:|441-getter|1|441-postInit
            form6.addCommand(getCancelCommand4());
            form6.addCommand(getItemCommand4());
            form6.setCommandListener(this);//GEN-END:|441-getter|1|441-postInit
            // write post-init user code here
        }//GEN-BEGIN:|441-getter|2|
        return form6;
    }
    //</editor-fold>//GEN-END:|441-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: cancelCommand5 ">//GEN-BEGIN:|454-getter|0|454-preInit
    /**
     * Returns an initiliazed instance of cancelCommand5 component.
     * @return the initialized component instance
     */
    public Command getCancelCommand5() {
        if (cancelCommand5 == null) {//GEN-END:|454-getter|0|454-preInit
            // write pre-init user code here
            cancelCommand5 = new Command("\u041E\u0442\u043C\u0435\u043D\u0430", Command.CANCEL, 0);//GEN-LINE:|454-getter|1|454-postInit
            // write post-init user code here
        }//GEN-BEGIN:|454-getter|2|
        return cancelCommand5;
    }
    //</editor-fold>//GEN-END:|454-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand8 ">//GEN-BEGIN:|457-getter|0|457-preInit
    /**
     * Returns an initiliazed instance of okCommand8 component.
     * @return the initialized component instance
     */
    public Command getOkCommand8() {
        if (okCommand8 == null) {//GEN-END:|457-getter|0|457-preInit
            // write pre-init user code here
            okCommand8 = new Command("OK", Command.OK, 0);//GEN-LINE:|457-getter|1|457-postInit
            // write post-init user code here
        }//GEN-BEGIN:|457-getter|2|
        return okCommand8;
    }
    //</editor-fold>//GEN-END:|457-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: textField22 ">//GEN-BEGIN:|450-getter|0|450-preInit
    /**
     * Returns an initiliazed instance of textField22 component.
     * @return the initialized component instance
     */
    public TextField getTextField22() {
        if (textField22 == null) {//GEN-END:|450-getter|0|450-preInit
            // write pre-init user code here
            textField22 = new TextField("Email \u0443\u0434\u0430\u043B\u044F\u0435\u043C\u043E\u0439 \u0437\u0430\u043F\u0438\u0441\u0438", null, 32, TextField.ANY);//GEN-LINE:|450-getter|1|450-postInit
            // write post-init user code here
        }//GEN-BEGIN:|450-getter|2|
        return textField22;
    }
    //</editor-fold>//GEN-END:|450-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: alert3 ">//GEN-BEGIN:|452-getter|0|452-preInit
    /**
     * Returns an initiliazed instance of alert3 component.
     * @return the initialized component instance
     */
    public Alert getAlert3() {
        if (alert3 == null) {//GEN-END:|452-getter|0|452-preInit
            // write pre-init user code here
            alert3 = new Alert("\u0423\u0434\u0430\u043B\u0435\u043D\u0438\u0435 \u0437\u0430\u043F\u0438\u0441\u0438", "", null, null);//GEN-BEGIN:|452-getter|1|452-postInit
            alert3.addCommand(getCancelCommand5());
            alert3.addCommand(getOkCommand8());
            alert3.setCommandListener(this);
            alert3.setTimeout(Alert.FOREVER);//GEN-END:|452-getter|1|452-postInit
            // write post-init user code here
        }//GEN-BEGIN:|452-getter|2|
        return alert3;
    }
    //</editor-fold>//GEN-END:|452-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: textField7 ">//GEN-BEGIN:|460-getter|0|460-preInit
    /**
     * Returns an initiliazed instance of textField7 component.
     * @return the initialized component instance
     */
    public TextField getTextField7() {
        if (textField7 == null) {//GEN-END:|460-getter|0|460-preInit
            // write pre-init user code here
            textField7 = new TextField("\u0422\u0435\u043C\u0430 \u0441\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u044F", null, 32, TextField.ANY);//GEN-LINE:|460-getter|1|460-postInit
            // write post-init user code here
        }//GEN-BEGIN:|460-getter|2|
        return textField7;
    }
    //</editor-fold>//GEN-END:|460-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand12 ">//GEN-BEGIN:|463-getter|0|463-preInit
    /**
     * Returns an initiliazed instance of backCommand12 component.
     * @return the initialized component instance
     */
    public Command getBackCommand12() {
        if (backCommand12 == null) {//GEN-END:|463-getter|0|463-preInit
            // write pre-init user code here
            backCommand12 = new Command("\u041D\u0430\u0437\u0430\u0434", Command.BACK, 0);//GEN-LINE:|463-getter|1|463-postInit
            // write post-init user code here
        }//GEN-BEGIN:|463-getter|2|
        return backCommand12;
    }
    //</editor-fold>//GEN-END:|463-getter|2|

    /**
     * Returns a display instance.
     * @return the display instance.
     */
    public Display getDisplay () {
        return Display.getDisplay(this);
    }

    /**
     * Exits MIDlet.
     */
    public void exitMIDlet() {
        switchDisplayable (null, null);
        destroyApp(true);
        notifyDestroyed();
    }

    /**
     * Called when MIDlet is started.
     * Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet.
     */
    public void startApp() {
        if (midletPaused) {
            resumeMIDlet ();
        } else {
            initialize ();
            startMIDlet ();
        }
        midletPaused = false;
    }

    /**
     * Called when MIDlet is paused.
     */
    public void pauseApp() {
        midletPaused = true;
    }

    /**
     * Called to signal the MIDlet to terminate.
     * @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released.
     */
    public void destroyApp(boolean unconditional) {

      if (getUserName().length() == 0)
          setUserName(" ");
      if (getUserPassword().length() == 0)
          setUserPassword(" ");
      if (getServerName().length() == 0)
          setServerName(" ");
      if (getServerPort().length() == 0)
          setServerPort(" ");

      if (connect){
          try {
            disconnectFromServer();
        } catch (RemoteException ex) {
        }
      }

      byte[] userByte = getUserName().getBytes();
      byte[] passByte = getUserPassword().getBytes();
      byte[] serverByte = getServerName().getBytes();
      byte[] portByte = getServerPort().getBytes();

     
      try {
            serviceStore = RecordStore.openRecordStore("Record", true);
            if (serviceStore.getNumRecords() > 0){
                serviceStore.setRecord(1, userByte, 0, userByte.length);
                serviceStore.setRecord(2, passByte, 0, passByte.length);
                serviceStore.setRecord(3, serverByte, 0, serverByte.length);
                serviceStore.setRecord(4, portByte, 0, portByte.length);
            }
            else{
                serviceStore.addRecord(userByte, 0, userByte.length);
                serviceStore.addRecord(passByte, 0, passByte.length);
                serviceStore.addRecord(serverByte, 0, serverByte.length);
                serviceStore.addRecord(portByte, 0, portByte.length);
            }
            serviceStore.closeRecordStore();
      }
      catch(Exception e){
      }

    }

    /**
     * Процедура для получения текущего положения от GPS - датчика устройства.
     * @return Координаты текущего местоположения
     */
    public static Coordinates getLocation(){
        Coordinates c = null;
        try {
          // Create a Criteria object for defining desired selection criteria
          Criteria cr = new Criteria();
          // Specify horizontal accuracy of 500 meters, leave other parameters
          // at default values.
          cr.setHorizontalAccuracy(500);
          LocationProvider lp = LocationProvider.getInstance(cr);
          // get the location, one minute timeout
          Location l = lp.getLocation(60);
          c = l.getQualifiedCoordinates();
        }
        catch (InterruptedException ex) {
        } catch (LocationException ex){
        }
        return c;
    }

    public final void setUserName(String Name){
        userName = Name;
    }

    public final String getUserName(){
        return userName;
    }

    public final void setUserPassword(String Pass){
       passwordUser = Pass;
    }

    public final String getUserPassword(){
        return passwordUser;
    }

    public final void setServerName(String Server){
        serverName = Server;
    }

    public static String getServerName(){
       return serverName;
    }

    public final void setServerPort(String Port){
        serverPort = Port;
    }

    public static String getServerPort(){
        return serverPort;
    }

    /**
     * 1. sessionKeyHash
       2. Guid юзера-получателя
       3. зашифрованная с помощью cryptAes ключом sessionKey тема сообщения
       4. зашифрованный с помощью cryptAes ключом sessionKey текст сообщения
     */
    public void sendMessage() throws DataLengthException, IllegalStateException, InvalidCipherTextException, UnsupportedEncodingException{
        String Message = textField4.getString();
        String title = textField7.getString();
        byte[] Mess = CryptoImpl.cryptAes(Message.getBytes("UTF-16LE"), sessionKey);
        byte[] tit = CryptoImpl.cryptAes(title.getBytes("UTF-16LE"), sessionKey);
        try {
            service.sendPM(bToS(sessionKeyHash), UserData.getId(), bToS(tit), bToS(Mess));
        } catch (RemoteException ex) {
        }
    }

    /**
     * Прием сообщений
     * @return
     */
    public boolean receiveMessage(){
        String Box;
    //    Box =GetPMIds(sessionKeyHash, 0); список ид сообщений
        String Message;
      //  Message = GetPM(bToS(sessionKeyHash), "1"); - получение сообщения с ид = 1
       // Message.msg_subject - тема сообщения
        //Message.msg_text - тело сообщения
        //Message.usr_from - от кого - идентификатор
        //Message.usr_to - кому
        return true;
    }

    /**
     * Получение списка пользователей, находящихся поблизости с клиентом.
     */
    public void getListUsers() throws RemoteException, IOException{
        String neig = "";
        String temp = "";
        try {
            ResultWithStatusOfstring neighborIds = service.getNeighborIds(bToS(sessionKeyHash));
            neig = neighborIds.getResult();
        } catch (RemoteException ex) {
        }
        int i;
        if (neig.length() != 0) {
            while ((i = neig.indexOf(",")) != -1){
              temp = neig.substring(0, i);
              getInfoUser(getXMLInfoForeignUser(temp), 1);
              list2.append(UserData.getFirst_name() + " " + UserData.getLast_name(), null);
              neig = neig.substring(i + 1);
            }
            getInfoUser(getXMLInfoForeignUser(neig), 1);
            list2.append(UserData.getFirst_name() + " " + UserData.getLast_name(), null);
        }
        else{
            switchDisplayable(null, getAlert2());
            alert2.setTitle("Список пуст");
            alert2.setString("Поблизости нет ни одного пользователя");
            list2.append("", null);
        }
    }

    /**
     *  Подключение к серверу
     * @param UserName - логин пользователя
     * @param Password - пароль пользователя
     * @return
     * @throws UnsupportedEncodingException
     * @throws DataLengthException
     * @throws IllegalStateException
     * @throws InvalidCipherTextException
     * @throws RemoteException
     */
    private static OperationStatus connectToServer(String UserName, String Password) throws UnsupportedEncodingException, DataLengthException, IllegalStateException, InvalidCipherTextException, RemoteException{

       sessionKey = CryptoImpl.getSessionKey();
       byte[] rsaCryptedSessionKey = CryptoImpl.rsaForKeyExchange(sessionKey);
       OperationStatus secondKeyExResult = service.keyExchange(UserName, bToS(rsaCryptedSessionKey));

       if (secondKeyExResult != OperationStatus.Success)
         return secondKeyExResult;

       sessionKeyHash = CryptoImpl.sha1(sessionKey);

       byte[] encryptedPassword = CryptoImpl.cryptAes(Password.getBytes("UTF-16LE"), sessionKey);

       OperationStatus authResult =  service.authenticate(bToS(sessionKeyHash), bToS(encryptedPassword));

       if (authResult == OperationStatus.Success){
          connect = true;
       }
       return authResult;
    }

    /**
     * Отключение от сервера
     * @throws RemoteException
     */
    private static OperationStatus disconnectFromServer() throws RemoteException{
      // Выход
      OperationStatus logoutResult = service.logout(bToS(sessionKeyHash));
      if (logoutResult == OperationStatus.Success)
        connect = false;
      return logoutResult;
      
    }

    /**
     * Регистрация новой учетной записи
     * @param UserName - учетная запись
     * @param Password - пароль
     * @throws InvalidCipherTextException
     * @throws RemoteException
     * @throws UnsupportedEncodingException
     */
    private static OperationStatus registerUser(String UserName, String Password) throws InvalidCipherTextException, RemoteException, UnsupportedEncodingException{
      // Для всех операций нужен клюс сеанса (sessionKey)
      // Сгенерить его можно, вызвав CryptoImpl#getSessionKey()
      sessionKey = CryptoImpl.getSessionKey();
      //byte[] sessionKey = Base64.decodeBase64("KXILeU0S0Te+TMbTEwlob6b1ctxoAr0n4FnkxrLrmK8=");
      // После генерации надо провести обмен ключами согласно PKCS#1, это делается
      // операцией KeyExchange, ей надо передать результат вызова
      // CryptoImpl#rsaForKeyExchange от сгенеренного ключа
      byte[] rsaCryptedSessionKey = CryptoImpl.rsaForKeyExchange(sessionKey);
      // Если пользователя пока не существует, в качестве e-mail юзера для обмена
      // ключами надо указать "*"
      OperationStatus keyExchangeResult = service.keyExchange("*", bToS(rsaCryptedSessionKey));
      if (keyExchangeResult != OperationStatus.Success)
        return keyExchangeResult;
      // Успешно обменялись ключами, теперь регистрируемся (операция Register):
      // передается sha1-хеш ключа сеанса, e-mail нового юзера и его пароль,
      // зашифрованный с ключом сеанса
      sessionKeyHash = CryptoImpl.sha1(sessionKey);
      byte[] encryptedPassword = CryptoImpl.cryptAes(Password.getBytes("UTF-16LE"), sessionKey);
      OperationStatus registerResult = service.register(bToS(sessionKeyHash), UserName, bToS(encryptedPassword));
      return registerResult;
      
    }

    /**
     * Удаление учетной записи
     * @param UserName - учетная запись
     * @throws RemoteException
     */
    private static OperationStatus deleteUser(String UserName) throws RemoteException, InvalidCipherTextException{

       sessionKey = CryptoImpl.getSessionKey();
       byte[] rsaCryptedSessionKey = CryptoImpl.rsaForKeyExchange(sessionKey);
       OperationStatus secondKeyExResult = service.keyExchange(UserName, bToS(rsaCryptedSessionKey));

       if (secondKeyExResult != OperationStatus.Success)
         return secondKeyExResult;

       sessionKeyHash = CryptoImpl.sha1(sessionKey);
        // Операция unregister = удаление зарегистрированного юзера
       OperationStatus unRegisterResult = service.unregister(bToS(sessionKeyHash), UserName);
       return unRegisterResult;
    }

    /**
     * Установка текущего положения клиента
     * @throws RemoteException
     */
    public static void setLocationUser() throws RemoteException{
        Coordinates Location;
        Location = getLocation();
        if (Location != null){
            OperationStatus setLocationUserResult =
                service.setLocation(bToS(sessionKeyHash), new Double(Location.getLatitude()), new Double(Location.getLongitude()));
        }
    }

    public static byte[] sToB(String str){
        return Base64.decode(str);
    }

    public static String bToS(byte[] bytes) {
        return new String(Base64.encode(bytes));
    }

    public static boolean getConnect(){
        return connect;
    }

    // Очистка данных
    public void clearInfo(){
       if (initial){
            stringItem1.setText("");
            stringItem5.setText("");
            stringItem15.setText("");
            stringItem6.setText("");
            stringItem2.setText("");
            stringItem9.setText("");
            stringItem10.setText("");
            stringItem12.setText("");
            stringItem11.setText("");
            stringItem13.setText("");
            stringItem14.setText("");
            stringItem7.setText("");
            stringItem16.setText("");
            stringItem17.setText("");
            stringItem18.setText("");
        }
    }

    public String getXMLInfoUser(){

        String InfoAboutUser = "";
        clearInfo();
        try {
            ResultWithStatusOfstring personalData = service.getPersonalData(bToS(sessionKeyHash));
            try {
                InfoAboutUser = new String(CryptoImpl.decryptAes(sToB(personalData.getResult()), sessionKey));
            } catch (DataLengthException ex) {
            } catch (IllegalStateException ex) {
           }
        } catch (RemoteException ex) {
        }
        return InfoAboutUser;
    }

    public String getXMLInfoForeignUser(String id_user) throws RemoteException{
        String InfoAboutUser = "";
        UserData.setId(id_user);
        clearInfo();
        ResultWithStatusOfstring foreignPersonalData = service.getForeignPersonalData(bToS(sessionKeyHash), id_user);
        try {
            InfoAboutUser = new String(CryptoImpl.decryptAes(sToB(foreignPersonalData.getResult()), sessionKey));
        } catch (DataLengthException ex) {
        } catch (IllegalStateException ex) {
        }
        return InfoAboutUser;
    }

    public void getInfoUser(String xmlStr, int State) throws IOException{
        // получение данных
        byte[] xmlByteArray = xmlStr.getBytes();
        ByteArrayInputStream xmlStream = new ByteArrayInputStream(xmlByteArray);
        InputStreamReader xmlReader = new InputStreamReader(xmlStream);
        XmlParser parser = new XmlParser(xmlReader);
        if (State == 0){
            try {
                traverse(parser);
            }
            catch (Exception exc){
            }
        }
        else
            if (State == 1){
                try {
                  traverse_name(parser);
                }
                catch (Exception exc){
                }
            }

    }

    /**
     * Разбор информации о пользователе и занесение в соответствующие значения.
     * @param parser
     * @throws Exception
     */
    public void traverse(XmlParser parser) throws Exception{
        boolean leave = false;
	do {
	  ParseEvent event = parser.read();
	  ParseEvent pe;
	  switch (event.getType() ) {
	  case Xml.START_TAG:
                 if ("usr_id".equals(event.getName())) {
			pe = parser.read();
	                guid = pe.getText();
		 }
                 if ("first_name".equals(event.getName())) {
			pe = parser.read();
	                stringItem1.setText(pe.getText());
		 }
                 if ("last_name".equals(event.getName())) {
			pe = parser.read();
                        stringItem5.setText(pe.getText());
		 }
                 if ("gender".equals(event.getName())) {
			pe = parser.read();
       	                stringItem15.setText(getGenderString(pe.getText()));
		 }
                 if ("date_of_birth".equals(event.getName())) {
			pe = parser.read();
       	                stringItem6.setText(pe.getText());
		 }
                 if ("hair_color".equals(event.getName())) {
			pe = parser.read();
	                stringItem2.setText(getHairColor(pe.getText()));
	   	 }
                 if ("eye_color".equals(event.getName())) {
			pe = parser.read();
	                stringItem9.setText(getEyeColor(pe.getText()));
		 }
                 if ("main_size".equals(event.getName())) {
			pe = parser.read();
	                stringItem10.setText(getMainSize(pe.getText()));
		 }
                 if ("orientation".equals(event.getName())) {
			pe = parser.read();
	                stringItem12.setText(getOrient(pe.getText()));
		 }
                 if ("zodiac".equals(event.getName())) {
			pe = parser.read();
	                stringItem11.setText(getZodiak(pe.getText()));
		 }
                 if ("reason".equals(event.getName())) {
			pe = parser.read();
	                stringItem13.setText(getReason(pe.getText()));
		 }
                 if ("interests".equals(event.getName())) {
			pe = parser.read();
	                stringItem14.setText(pe.getText());
		 }
                 if ("bio".equals(event.getName())) {
			pe = parser.read();
       	                stringItem7.setText(pe.getText());
		 }
                 if ("phone_number".equals(event.getName())) {
			pe = parser.read();
	                stringItem16.setText(pe.getText());
		 }
                 if ("icq".equals(event.getName())) {
			pe = parser.read();
	                stringItem17.setText(pe.getText());
		 }
                 if ("jabber".equals(event.getName())) {
			pe = parser.read();
	                stringItem18.setText(pe.getText());
		 }
                 traverse(parser);
		 break;
	  case Xml.END_TAG:
		break;
	  case Xml.END_DOCUMENT:
		leave = true;
		break;
	  case Xml.TEXT:
		break;
	  case Xml.WHITESPACE:
		break;
	  default:
	  }
	} while( !leave );
    }

    /**
     * Получение имени и фамилии пользователя для списка и занесение его в персональные данные.
     * @param parser
     * @throws IOException
     */
    private void traverse_name(XmlParser parser) throws IOException {
        boolean leave = false;
	do {
	  ParseEvent event = parser.read();
	  ParseEvent pe;
	  switch (event.getType() ) {
	  case Xml.START_TAG:
                 if ("first_name".equals(event.getName())) {
			pe = parser.read();
                        UserData.setFirst_name(pe.getText());
                 }
                 if ("last_name".equals(event.getName())) {
			pe = parser.read();
                        UserData.setLast_name(pe.getText());
		 }
                 traverse_name(parser);
		 break;
	  case Xml.END_TAG:
		break;
	  case Xml.END_DOCUMENT:
		leave = true;
		break;
	  case Xml.TEXT:
		break;
	  case Xml.WHITESPACE:
		break;
	  default:
	  }
	} while( !leave );
    }

    /**
     * Перевод значение пола из числа в строку
     * @param Gen
     * @return
     */
    private String getGenderString(String Gen){
        switch (Integer.parseInt(Gen)){
            case 0:
                return "Мужской";
            case 1:
                return "Женский";
            default:
                return "Неопределенный";
        }
    }

    /**
     * Перевод значение цвета волос из числа в строку
     * @param Color
     * @return
     */
    private String getHairColor(String Color){
        switch (Integer.parseInt(Color)){
            case 0:
                return "Блондин";
            case 1:
                return "Брюнет";
            case 2:
                return "Шатен";
            case 3:
                return "Светло - русые";
            case 4:
                return "Русые";
            case 5:
                return "Рыжие";
            default:
                return "Черный";
        }
    }

    /**
     * Перевод значения цвета глаз из числа в строку
     * @param Color
     * @return
     */
    private String getEyeColor(String Color){
        switch (Integer.parseInt(Color)){
            case 0:
                return "Карие";
            case 1:
                return "Голубые";
            case 2:
                return "Зеленые";
            case 3:
                return "Серые";
            case 4:
                return "Серо - голубые";
            case 5:
                return "Красные";
            default:
                return "";
        }
    }

    /**
     * Перевод значения знака зодиака
     * из числа в строку
     * @param Zodiak
     * @return
     */
    private String getZodiak(String Zodiak){
        switch (Integer.parseInt(Zodiak)){
            case 0:
                return "Водолей";
            case 1:
                return "Рыбы";
            case 2:
                return "Овен";
            case 3:
                return "Телец";
            case 4:
                return "Близнецы";
            case 5:
                return "Рак";
            case 6:
                return "Лев";
            case 7:
                return "Дева";
            case 8:
                return "Весы";
            case 9:
                return "Скорпион";
            case 10:
                return "Стрелец";
            case 11:
                return "Козерог";
            default:
                return "";
        }
    }

    /**
     * Перевод цели знакомства из численного значения в строку
     * @param Reason
     * @return
     */
    private String getReason(String Reason){
        switch (Integer.parseInt(Reason)){
            case 0:
                return "Спонсор";
            case 1:
                return "Друг";
            case 2:
                return "Любовник";
            case 3:
                return "Пара";
            case 4:
                return "Развлечения";
            default:
                return "";
        }
    }

    /**
     * Перевод ориентации из численного значения в строку
     * @param Orient
     * @return
     */
    private String getOrient(String Orient){
        switch (Integer.parseInt(Orient)){
            case 0:
                return "Традиционная";
            case 1:
                return "Нетрадиционная";
            case 2:
                return "Бисексуал";
            default:
                return "";
        }
    }

    /**
     * Перевод основного размера из численного значения в строку
     * @param Size
     * @return
     */
    private String getMainSize(String Size){
        switch (Integer.parseInt(Size)){
            case 0:
                return "Экстра кинг сайз";
            case 1:
                return "Большие";
            case 2:
                return "Средние";
            case 3:
                return "Обычные";
            case 4:
                return "Маловато";
            default:
                return "";
        }
    }
}